import { Component, OnInit } from '@angular/core';
import { DropdownConfig } from 'ng2-bootstrap/dropdown';

import { UserDetail } from './shared/user-detail.model';
import { UserDetailService } from './shared/user-detail.service';

export function getDropdownConfig(): DropdownConfig {
  return Object.assign(new DropdownConfig(), {autoClose: 'disabled', keyboardNav: true});
}

@Component({
	selector: 'user-detail',
	templateUrl: 'user-detail.component.html',
	providers: [UserDetailService,{provide: DropdownConfig, useFactory: getDropdownConfig}]
})

export class UserDetailComponent implements OnInit {
	userDetail: UserDetail[] = [];

	constructor(private userDetailService: UserDetailService) { }

	ngOnInit() {
		this.userDetailService.getList().subscribe((res) => {
			this.userDetail = res;
		});
	}
}